/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.feerepository.client.components;

import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.TreeListener;
import java.util.Collection;
import org.feerepository.client.AppEventListerImpl;
import org.feerepository.client.model.AreaModel;
import org.feerepository.client.views.IAreasView;

/**
 *
 * @author Oleg
 */
public class AppMenu extends Tree implements IAreasView
{
    IndexedTreeItem currentArea;
    public AppMenu()
    {
        this.setStyleName("jurisdictionMenu");
        this.addTreeListener(new TreeListener(){

            public void onTreeItemSelected(TreeItem item)
            {
                AppEventListerImpl.getInstance().mainMenuItemSelected(item);
            }

            public void onTreeItemStateChanged(TreeItem item) {
                //throw new UnsupportedOperationException("Not supported yet.");
            }

        });
    }

    public void updateView(Collection<AreaModel> areas) {
        throw new UnsupportedOperationException("Update area menu view from Area Model is not supported yet.");
    }

    public void addArea(String name, int id)
    {
       currentArea = new IndexedTreeItem(name);
       currentArea.setId(id);
       this.addItem(currentArea);
    }

    public void addJurisdiction(String name, int id) {
        IndexedTreeItem item = new IndexedTreeItem(name);
                item.setId(id);
        currentArea.addItem(item);
    }

}
